package com.shsmi.jc.seed.service.impl;

import cn.hutool.core.util.StrUtil;
import com.shsmi.jc.seed.common.ErrorCode;
import com.shsmi.jc.seed.entity.MapInstance;
import com.shsmi.jc.seed.entity.SystemUser;
import com.shsmi.jc.seed.exception.MyException;
import com.shsmi.jc.seed.repository.MapInstanceRepository;
import com.shsmi.jc.seed.repository.SystemUserRepository;
import com.shsmi.jc.seed.service.AuthService;
import com.shsmi.jc.seed.service.MapInstanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

@Service
public class MapInstanceServiceImpl implements MapInstanceService {

    @Autowired
    private MapInstanceRepository repository;

    @Override
    public Page<MapInstance> listAll(Example<MapInstance> example, Pageable pageable) {
        return repository.findAll(example,pageable);
    }

    @Override
    public MapInstance getById(Long id) throws MyException {
        return repository.findById(id).orElseThrow(()->new MyException(ErrorCode.GLOBAL_DATA_NOT_EXIST,"数据不存在"));
    }

    @Override
    public MapInstance insert(MapInstance record) {
        return repository.save(record);
    }

    @Override
    public MapInstance update(MapInstance record) {
        return repository.save(record);
    }

    @Override
    public void delete(Long id) {
        repository.deleteById(id);
    }
}
